package com.shiro.shiroweb.dao;

import com.shiro.shiroweb.entity.RoleEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Set;

@Repository
public interface RoleRepository extends JpaRepository<RoleEntity,String> {
    @Query(value = "SELECT r.role FROM ts_user_role AS ts " +
            "INNER JOIN  user  AS u ON u.id = ts.user_id " +
            "INNER JOIN role AS r ON ts.role_id = r.id " +
            "WHERE u.name=?1 ",nativeQuery = true)
    Set<String> findRolesByUsername(String username);
}
